﻿using System.Collections.Generic;
using CCS.BLL.DTO;
using CIK.Framework.Extensions;

namespace CCS.BLL.Impl
{
    using DAL.Repository;
    using DAL.Repository.Impl;

    public class CategoryManager : ICategoryManager
    {
        private readonly ICategoryRepository _repository;

        public CategoryManager() : this(new CategoryRepository())
        {
        }

        public CategoryManager(ICategoryRepository repository)
        {
            _repository = repository;
        }

        public CategoryDto GetById(int id)
        {
            return _repository.Single(x => x.Id == id).MapTo<CategoryDto>();
        }

        public IEnumerable<CategoryDto> GetAll()
        {
            var categories = _repository.GetAll();

            return categories.MapTo<CategoryDto>();
        }
    }
}